home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1674 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  58 lines

  1. Path: ns.etri.re.kr!jinsoo
  2. From: jinsoo@etri.re.kr (Jin-Soo Lee)
  3. Newsgroups: comp.lang.c
  4. Subject: HELP: What is wrong ?
  5. Date: 16 Jan 1996 02:40:35 GMT
  6. Organization: Electronics and Telecommunications Research Inst. (ETRI)
  7. Message-ID: <4df373$kd3@ns.etri.re.kr>
  8. Reply-To: jinsoo@dbserver.etri.re.kr
  9. NNTP-Posting-Host: musso.etri.re.kr
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12.  Your KIND HELP is needed.
  13.  I have some problems in the following code.
  14.  
  15. ---------
  16.  
  17. #define DSKPAGESIZE     16*1024
  18. #define LOGBUFSIZE      2*DSKPAGESIZE
  19.  
  20. main()
  21. {
  22.     int    pageBS, logoffset, bufferoffset, buffersize, length;
  23.     int    freespace, inusefile;
  24.     char    *globla_page;
  25.     T_LOGRECORD    *tlogrec;
  26. ....
  27. (1)     pageBS = (logoffset/LOGBUFSIZE) * LOGBUFSIZE;
  28. ....
  29. (2)     bufferoffset = (logoffset + length)%LOGBUFSIZE;
  30. ....
  31. (3)     tlogrec = (T_LOGRECORD *)(global_page + (logoffset%LOGBUFSIZE));
  32. ....
  33.         freespace = inuselogfile - logoffset;
  34. (4)     if (freespace - length > sizeof(int))
  35. ....
  36.         freespace = buffersize - bufferoffset;
  37. (5)     if (freespace - length >= sizeof(int))
  38. ....
  39. }
  40.  
  41. ---------
  42.  
  43.  The code worked well on SUN OS 4.1.3. and K&R C with dbx,
  44.  but goes wrong when moved to current environment,
  45.  Solaris 2.4 and SUN C with SparcWorks dbx and gcc with gdb.
  46.  The statements (1) ~ (5) sometimes make too big or negative values.
  47.  I can't believe it.
  48.  What happened ?
  49.  OS or compiler problem ? or C language syntax problem ?
  50.  
  51.  Any help is greatly appreciated. Please e-mail me.
  52.  
  53. --
  54. Jin-Soo Lee            Internet: jinsoo@dbserver.etri.re.kr
  55. DB Section, Electronics and Telecommunications Research Inst. (ETRI)
  56. P.O. Box 106, You-Seong, Taejon, 305-600, Korea
  57. TEL: +82-42-860-4865                            FAX: +82-42-860-6645
  58.